package com.medibooking.gwt.client.celendar.appointment;

import java.util.Date;

import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.medibooking.gwt.client.javascript.NativeSelectionFunction;
import com.medibooking.gwt.client.resources.CalendarResources;


public class AppointmentWidget {

    private HTMLPanel appoitmentElement;
    private Element parentElement;
    private Date Date;
    private double startHour;
    private double endHour;
    
    private int height;
    private int width;
    private int left;
    private int top;
    
    private void setElementPosition() {
        StringBuilder sb = new StringBuilder();
        sb.append("top: ").append(top).append("px").append(";");
        sb.append("left: ").append(left).append("px").append(";");
        sb.append("height: ").append(height).append("px").append(";");
        sb.append("width: ").append(width).append("px").append(";");
        appoitmentElement.getElement().setAttribute("style", sb.toString());
    }

    public AppointmentWidget(Element parentElement, Element referenceElement, int top) {
        this.parentElement = parentElement;        
        this.left = referenceElement.getOffsetLeft();
        this.top = referenceElement.getOffsetTop();
        
        this.height = referenceElement.getClientHeight();
        this.width = referenceElement.getClientWidth();
        
        //Create a div
        appoitmentElement = new HTMLPanel("----");
        setElementPosition();
        
      //  appoitmentElement.getElement().setAttribute("style", "top: "+referenceElement.getAbsoluteTop()+"px");
        
        appoitmentElement.setStyleName(CalendarResources.instance.css().appointmentWidget());
        
        this.parentElement.appendChild(appoitmentElement.getElement());
        NativeSelectionFunction.disableTextSelectInternal(appoitmentElement.getElement(), true);
        

    }

    public void setParentElement(Element parentElement) {
        this.parentElement = parentElement;
    }

    public Element getParentElement() {
        return parentElement;
    }

    public void setDate(Date date) {
        Date = date;
    }

    public Date getDate() {
        return Date;
    }

    public void setStartHour(double startHour) {
        this.startHour = startHour;
    }

    public double getStartHour() {
        return startHour;
    }

    public void setEndHour(double endHour) {
        this.endHour = endHour;
    }

    public double getEndHour() {
        return endHour;
    }

}